package com.chhlz.module.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chhlz.module.base.dao.DishCategoryDao;
import com.chhlz.module.base.model.DishCategory;
import com.chhlz.module.service.DishCategoryService;


/**
 * 菜式类型业务
 * @author ALEXGORDON
 *
 */
@Service
public class DishCategoryServiceImpl implements DishCategoryService {
	@Autowired
	private DishCategoryDao DishCategoryDao;

	@Override
	public int getTotal() {
		return DishCategoryDao.countAll();
	}
	@Override
	public boolean isExist(String dcName) {
		boolean flag = false;
		String hql="from DishCategory as c where c.dcName="+dcName;
		if (DishCategoryDao.find(hql).size()>0){
			flag = true;
		}
		return flag;
	}
	@Override
	public int save(DishCategory t) {
		return this.DishCategoryDao.save(t);
	}
	@Override
	public void update(DishCategory t) {
		this.DishCategoryDao.update(t);
	}
	@Override
	public void delete(int id) {
		DishCategory dc = this.DishCategoryDao.get(id);
		this.DishCategoryDao.delete(dc);
	}
	@Override
	public List<DishCategory> findAll(int page, int rows, String sort,
			String order) {
		return this.DishCategoryDao.findAll(page, rows, sort, order);
	}
}
